var MailStarList = Class.create();
MailStarList.prototype = {
	initialize: function() {
                        this._is_init = 0;
                        this._opt_id = 0;
                        this._lst_mid = 0;
                        this.clickObj = null;
                    },
        initEvent : function(){
                         var self = this;
                         var _tmp_dl = [{
                            name: 'list_star'
                         }];
                        Event.observe(DOM.mailList, 'click', function(event){
                                var EL = event.target;
                                var e = Element.getParentNodeByClassName(EL, 'list_star');
                                if(!e){
                                    return false;
                                }
                                var selallid = EL.level ? EL.level : EL.getAttribute('level');
                                if(isConferenceMode){
                                mailConference.clearListCache(mailConference.folder);
                                mailConference.clearListCache(1);
                                mailStarList.clickObj = selallid;
                                }
			        changePanel('mailList', selallid);
                        });
                        this.rebuild();
                     },
        reset_selected : function(){
                                var star_list = $('top_tr_list').getElementsByClassName('list_star');
                                for(var i = 0; i < star_list.length; i++){
                                    var item = star_list[i];
                                    var selallid = item.level ? item.level : item.getAttribute('level');
                                    if(Element.hasClassName(item, 'star_selected')){
                                        Element.removeClassName(item, 'star_selected');
                                    }
                                    if(isConferenceMode){
                                        if(selallid == mailConference.folder && !Element.hasClassName(item, 'star_selected')){
                                            Element.addClassName(item, 'star_selected');
                                        }
                                    }
                                    else{
                                        if(selallid == mailList.currentFolder && !Element.hasClassName(item, 'star_selected')){
                                            Element.addClassName(item, 'star_selected');
                                        }
                                    }
                                }
                         },
        update_folder_cache : function(ret){
                                  if (ret == 1) {
                                      FolderList.each(function(item){
                                              if (item.folder_id == -5) {
                                                    if(mailStarList._opt_id == 1){
                                                        item.total += 1;
                                                    }
                                                    if(mailStarList._opt_id == 0){
                                                        item.total -= 1;
                                                    }
                                                }
                                                });
                                  }
                      },
        get_list_pre : function(mailnum){
                           var mode_sp = 'id="selectAllBoxID"';
                           if(isConferenceMode){
                               mode_sp = 'id="conference_all" class="conference_all" name=""';
                           }
                           return '<tr id="top_tr_list" class="top_tr bb"><td colspan=9><ul style="padding:0px;height:25px;margin:0px;margin-top:5px;"><li style="display:block;float:left;width:12px">&nbsp;</li><li style="float:left;width:130px;"><div style="float:left;width:130px;"> <input ' + mode_sp + ' type="checkbox" style="display:block;float:left"/><span style="display:block; margin-top:-3px; float:left;"> 全选 / 取消全选 </span></div></li><li style="width:35px;float:left;margin-top:2px;"><span title="全部" level="-5" class="am list_star " style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span level="-5" style="margin-top:-3px;" class="list_star star_selected">全部</span></a></li><li style="width:55px;float:left;margin-top:2px;"><span title="重要" level="-16" class="am  list_star icon_star1" style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span level="-16"  style="margin-top:-3px;" class="list_star">重要</span></a></li><li style="width:60px;float:left;margin-top:2px;"><span title="关注" level="-19" class="am  list_star icon_star2" style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span class="list_star"  style="margin-top:-3px;" level="-19">关注</span></a></li><li style="width:65px;float:left;margin-top:2px;"><span title="已完成" level="-18" rid="1590" class="am  list_star icon_star3" style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span level="-18" style="margin-top:-3px;" class="list_star">已完成</span></a></li><li style="width:80px;float:left;margin-top:2px;"><span title="后序工作" level="-17" rid="1590" class="am list_star icon_star4" style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span level="-17" style="margin-top:-3px;" class="list_star" >后序工作</span></a></li><li style="width:65px;float:left;margin-top:2px;"><span title="有疑问" level="-20" class="am  list_star icon_star5" style="color: rgb(119, 51, 170);float:left;"></span><a href="javascript:;"><span class="list_star"  style="margin-top:-3px;" level="-20">有疑问</span></a></li><li style="width=175px;float:right;text-align:right;line-height:20px;"><span style="margin-right:16px;_margin-right:16px;">' + mailnum + '</span></li><ul></td></tr>';
                       },
rebuild : function(){
                        // var EL = document.getElementsByClassName('s_starmail')[0];
						$('folder_-5')[(PROFILE.star_list || PROFILE.star_list == 'true') ? 'show' : 'hide']();
						/*
						var EL = $('folder_-5');
                        var display = (PROFILE.star_list == true || PROFILE.star_list == "true") ? '' : 'none';
                        Element.setStyle(EL, {'display' : display});
                        */

          }
};


var mailStarList = new MailStarList();
